import requests
from bs4 import BeautifulSoup
import random
import time
import os
import xlrd

import requests
import json
url = 'http://icanhazip.com'
proxy = { "http":"35.224.248.29:3128", }
response = requests.get(url,proxies=proxy)
print(response.text)
#读取json文件
file = open('test.json','r',encoding='utf-8')
s = json.load(file)
print (s[0]['name'])

# wb = xlrd.open_workbook(r"C:\Users\liuyuanting\Desktop\cookie.xlsx")
# sh = wb.sheet_by_index(0)
# # for i in range(1, sh.nrows):
# while True:
#     row=random.randint(1,sh.nrows-1)
#     sessionid = sh.cell_value(row, 0)
#     sessionip = sh.cell_value(row, 1)
#     ua = sh.cell_value(row, 2)
#
#     cookie = "sessionid=" + sessionid + ''';sessionip=''' + '35.224.248.29' + ''';__ah_uuid=8B73372D-5A84-43F4-8269-961E28197B73;fvlid=1541678060619Ng53p3xrWJ; ahpau=1; sessionuid=CD903D28-9703-4BCB-B579-7DB60DB4B93C%7C%7C2018-11-08+19%3A54%3A25.096%7C%7C0; Hm_lvt_9924a05a5a75caf05dbbfb51af638b07=1541732696,1541904234;; area=110108;sessionvid=39D34F48-B2C5-4D35-895E-E09622D91F6F;ahpvno=446;ref=0%7C0%7C0%7C0%7C2018-11-12+18%3A49%3A55.821%7C2018-11-08+19%3A54%3A25.096'''
#     print(row,cookie)
#     header = {
#         'User-Agent': ua,
#         'Connection': 'keep-alive',
#         'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
#         'Cookie': cookie}
#
#     try:
#         url = 'https://www.autohome.com.cn/advice/201810/923804.html'
#         wbdata = requests.get(url, headers=header).text
#     except:
#         print("no")